var tmAdmin = {
		initPage:function(itemsCount){
			$(".tmpage").tzPage(itemsCount, {
			num_display_entries : 5, //主体页数
			num_edge_entries : 4,//边缘页数
			current_page : 0,//指明选中页码
			items_per_page : 10, //每页显示多条条
			prev_text : "上一页",
			next_text : "下一页",
			showGo:true,//显示
			showSelect:true,
			callback : function(pageNo, psize) {//会回传两个参数一个当前页，显示的页数
				tmAdmin.loadData(pageNo,psize);
			}
		});
	},
	loadData:function(pageNo,pageSize,callback){
		$.ajax({
			type:"post",
			url:basePath+"/admin/loadData.do",
			data:{pageNo:pageNo*pageSize,pageSize:pageSize},
			success:function(data){
				$("#tmblog").html(data);
				var itemsCount = $(data).find("#itemsCount").val();
				if(callback)callback(itemsCount);
			}
		});
	},
	change:function(obj){
		var id = $(obj).attr("opid");
		var status = $(obj).attr("status");
		var isTop = $(obj).attr("istop");
		var tag = $(obj).attr("tag");
		var params = null;
		if(tag==1){
			isTop = (isTop==1?0:1);
			params = {id:id,isTop:isTop};
		}else{
			status = status==1?0:1;
			params = {id:id,status:status};
		}
		$(obj).toggleClass("green red").html(tag==1?(isTop==1?"是":"否"):(status==1?"发布":"未发布"));
		$(obj).attr("istop",isTop);
		$(obj).attr("status",status);
		$.ajax({
			type:"post",
			url:basePath+"/admin/update.do",
			data:params,
			success:function(data){
				tzMessage.tip("操作成功！");
			}
		});
	},
	del:function(obj){
		var id = $(obj).attr("opid");
		$.ajax({
			type:"post",
			url:basePath+"/admin/delete.do",
			data:{id:id},
			success:function(data){
				if(data=="success"){
					tzMessage.tip("删除成功！");
					$(obj).parents("tr").toggle("slow",function(){
						$(this).remove();
					});
					
				}else{
					tzMessage.tip("删除失败！");
				}
			}
		});
	}
};